import { Router, Route, Redirect } from 'react-router-dom'

import { history } from '@/utils'

import Login from './pages/Login'
import Layout from './pages/Layout'
import ProfileEdit from './pages/Profile/Edit'
import Search from './pages/Search'
import SearchResult from './pages/Search/Result'
import Article from './pages/Article'
import ProfileChat from './pages/Profile/Chat'

const App = () => {
  return (
    <Router history={history}>
      <div className="app">
        <Route exact path="/" render={() => <Redirect to="/home" />}></Route>
        <Route path="/login">
          <Login />
        </Route>
        <Route path="/home">
          <Layout />
        </Route>
        <Route path="/profile/edit">
          <ProfileEdit />
        </Route>
        <Route exact path="/search">
          <Search />
        </Route>
        <Route path="/search/result">
          <SearchResult />
        </Route>
        <Route path="/article/:id">
          <Article />
        </Route>
        <Route path="/chat">
          <ProfileChat />
        </Route>
      </div>
    </Router>
  )
}

export default App
